package com.example.blog.base;

import com.example.blog.entity.SysUser;
import lombok.Data;

import java.io.Serializable;

/**
 * @ClassName CurrentAccount
 * @Description TODO
 * @Author Wang Li Hong
 * @date 2024/1/5 15:54
 * @Version 1.0
 */
@Data
public class CurrentAccount {

    private Long id;

    private String nickname;

    private String role;

    private String token;

    public CurrentAccount(Long id, String nickname, String role, String token) {
        this.id = id;
        this.nickname = nickname;
        this.role = role;
        this.token = token;
    }


    public static CurrentAccount userToCurrentAccount(SysUser user, String token) {
        return new CurrentAccount(user.getId(),user.getNickname(),"USER", token);
    }
}
